package com.example.a2018.myapplication;

import android.content.Intent;
import android.media.Image;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Spinner;

/**
 * Created by Gou Ziyi on 2018/9
 */
public class MainActivity extends AppCompatActivity {

    //点击跳转事件函数封装
    public void jump( int id,Class<?> jumpactivity){
        View view= (View)findViewById(id);
        final Intent intent = new Intent(MainActivity.this,jumpactivity);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);//关掉所要到的界面中间的activity
        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);//设置不要刷新将要跳转的界面
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(intent);
            }
        });
    }

    //下拉框选择函数封装 spinner
    public void choose (int R_id,final int array_id){
        Spinner spinner = (Spinner) findViewById(R_id);
        spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view,
                                       int pos, long id) {
                String[] array = getResources().getStringArray(array_id);

            }
            @Override
            public void onNothingSelected(AdapterView<?> parent) {
                // Another interface callback
            }
        });
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        jump(R.id.scan,QrcodeActivity.class);
        jump(R.id.go_back,EquipmentActivity.class);
    }

}
